package com.jt.demo01_CGLIB;
/**CGLIB动态代理入门*/
import com.jt.demo01_CGLIB.config.SpringConfig;
import com.jt.demo01_CGLIB.proxy.CglibProxy;
import com.jt.demo01_CGLIB.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class CGBLIB_Tx {
    public static void main(String[] args) {

        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
        UserService userService = context.getBean(UserService.class);
        //使用代理对象 调用方法
        UserService proxy = (UserService) CglibProxy.getObject(userService);
        proxy.addUser();

    }
}
